<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/8/11
 * Time: 15:28
 */

function linkurl($url,$data,$type){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    if($type == 1){
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // post数据
        curl_setopt($ch, CURLOPT_POST, 1);
        // post的变量
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_TIMEOUT, 1);
    }
    else if($type == 2){
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    }

    $output = curl_exec($ch);
    curl_close($ch);
    return $output;
}

function   wk($date1) {
    $datearr = explode("-",$date1);     //将传来的时间使用“-”分割成数组
    $year = $datearr[0];       //获取年份
    $month = sprintf('%02d',$datearr[1]);  //获取月份
    $day = sprintf('%02d',$datearr[2]);      //获取日期
    $hour = $minute = $second = 0;   //默认时分秒均为0
    $dayofweek = mktime($hour,$minute,$second,$month,$day,$year);    //将时间转换成时间戳
    $shuchu = date("w",$dayofweek);      //获取星期值
    $weekarray=array("7","1","2","3","4","5","6");
    return $weekarray[$shuchu];
}

function getUserFromWid($wgateid){
    $user = M('user')->where(array('wgateid'=>$wgateid,'del'=>0))->field('id,name,photo,type')->find();
    // return M('user')->getLastSql();die;
    if(count($user) == 0){
        return '';
    }
    else{
        return $user;
    }
}
